<template>
	<el-table :data="tableData" border highlight-current-row @selection-change="selectionChange">
		<el-table-column type="selection" align="center"></el-table-column>
		<el-table-column type="index" label="序号" width="70" align="center"></el-table-column>
		<el-table-column property="code" label="编码" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column property="name" label="名称" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column property="type" label="类别" align="center">
            <template slot-scope="scope">
                <span>{{ scope.row.typeName }}</span>
            </template>
        </el-table-column>
        <el-table-column property="balanceDirection" label="余额方向" align="center">
        	<template slot-scope="scope">
                <span v-if="(scope.row.code.split('.')[0].length != 5 && scope.row.balanceDirection == 0) && (scope.row.code.split('.')[0].length != 3 && scope.row.balanceDirection == 0)">借方</span>
                <span v-if="(scope.row.code.split('.')[0].length != 5 && scope.row.balanceDirection == 1) && (scope.row.code.split('.')[0].length != 3 && scope.row.balanceDirection == 1)">贷方</span>
            </template>
        </el-table-column>
        <el-table-column property="foreignCurrencyCheck" label="外币核算" align="center">
        	<template slot-scope="scope">
                <span v-if="scope.row.foreignCurrencyCheck == 0">不核算</span>
                <span v-for="item in allUnitTypes" :key="item['id']">
                    <i style="font-style: normal !important;" v-if="item['id'] == scope.row.foreignCurrencyCheck">{{ item['name'] }}</i>
                </span>
                <span v-if="scope.row.foreignCurrencyCheck == 1002">所有币别</span>
            </template>
        </el-table-column>
        <el-table-column property="journal" label="出日记账" align="center">
        	<template slot-scope="scope">
                <el-checkbox v-model="!!scope.row.journal" disabled></el-checkbox>
            </template>
        </el-table-column>
        <el-table-column property="betweenObjects" label="往来科目" align="center">
        	<template slot-scope="scope">
                <el-checkbox v-model="!!scope.row.betweenObject" disabled></el-checkbox>
            </template>
        </el-table-column>
        <el-table-column property="locks" label="状态" align="center">
        	<template slot-scope="scope">
                <span v-if="scope.row.locks === 0" style="color: #f00;">已禁用</span>
                <span v-if="scope.row.locks === 1" style="color: green;">已启用</span>
            </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
            <template slot-scope="scope">
                <span class="update-span" @click="update(scope.row.id)">修改</span>
            </template>
        </el-table-column>
	</el-table>
</template>
<script>
export default {
	data() {
		return {
			tableData: this.$store.state.accountSubjectStore.tableData,
			allUnitTypes: [],		//外币核算单位
		}
	},
	methods: {
		selectionChange(arr) {
            this.$store.commit('accountSubjectStore/multipleSelection', arr);
		},
		update(id) {
            this.$store.commit('accountSubjectStore/updateRowId', id);
            this.$util.openLayerIframe({title: '会计科目-修改', zIndex: 13, width: '600px', height: '480px', url: this.$domain + '/#/basicData/accountSubject/tab'});
		}
	}
}
</script>